package com.sky.controller.User;
import java.util.List;
import com.sky.entity.Setmeal;
import com.sky.result.Result;
import com.sky.service.SetmealService;
import com.sky.vo.DishItemVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/user/setmeal")
@Api("查询套餐")
@Slf4j
public class UserSetmealController {
@Autowired
private SetmealService setmealService;

    /**
     * 根据分类查询套餐
     * @param categoryId
     * @return
     */
    @GetMapping("/list")
    @ApiOperation("查询套餐")
    @Cacheable(cacheNames = "setmeal_",key = "#categoryId")
public Result<List<Setmeal>> list(Long categoryId) {
        log.info("查询套餐{}", categoryId);
   List<Setmeal>lists =setmealService.selectByCategoryId(categoryId);
   return Result.success(lists);
    }

    /**
     * 查询套餐餐品
     * @return
     */
    @GetMapping("/dish/{id}")
    @ApiOperation("查询套餐的菜品")
    public Result<List<DishItemVO>> Dishlist(@PathVariable Long id){
        log.info("查询套餐中的菜品:{}",id);
       List<DishItemVO>list = setmealService.SelectDish(id);
       return Result.success(list);
    }
}
